#ifndef PROTREEWIDGET_H
#define PROTREEWIDGET_H
#include <QTreeWidget>
#include <QSet>
#include <QAction>
#include <QProgressDialog>
#include <QtMultimedia/QMediaPlayer>
#include <QtMultimedia/QMediaPlaylist>
#include "protreethread.h"
#include "opentreethread.h"

class SlideShowDialog;
class ProTreeWidget : public QTreeWidget
{
    Q_OBJECT
public:
    ProTreeWidget(QWidget *parent = nullptr);

    void AddProToTree(const QString name,const QString path);
private:
    QSet<QString> _set_path;
    //右键单机某个item之后弹出来
    QTreeWidgetItem* _right_btn_item;
    QTreeWidgetItem* _active_item;
    QTreeWidgetItem* _selected_item;
    QAction* _action_import;
    QAction* _action_setstart;
    QAction* _action_closepro;
    QAction* _action_slideshow;
    QProgressDialog* _dialog_progress;
    QProgressDialog* _open_progressdlg;
    std::shared_ptr<ProTreeThread> _thread_create_pro;
    std::shared_ptr<OpenTreeThread> _thread_open_pro;
    std::shared_ptr<SlideShowDialog> _slide_show_dlg;
    QMediaPlayer* _player;
    QMediaPlaylist* _playlist;
private slots:
    void SlotItemPressed(QTreeWidgetItem* pressedItem,int column);
    void SlotImport();
    void SlotSetActive();
    void SlotClosePro();
    void SlotUpdateProgress(int count);
    void SlotFinishProgress();
    void SlotCancelProgress();

    void SlotUpOpenProgress(int count);
    void SlotFinishOpenProgress();
    void SlotCancelOpenProgress();

    void SlotDoubleClickedItem(QTreeWidgetItem *item, int column);
    void SlotSlideShow();
public slots:
    void SlotOpenPro(const QString& path);
    void SlotPreShow();
    void SlotNextShow();

    void SlotSetMusic();
    void SlotStartMusic();
    void SlotStopMusic();
signals:
    void SigCancelProgress();
    void SigCancelOpenProgress();//向"打开"对话框发送信号
    void SigUpdateSelected(const QString& path);
    void SigUpdatePic(const QString& path);
    void SigClearSelected();
};

#endif // PROTREEWIDGET_H
